package com.project.common.core.utils.file;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wyy
 * @date 2019-08-21 23:50
 */
public class FilePathConsts {
    // 媒体文件
    public static final String FILE_MEDIA_PATH = "/upload/media";

    // 二维码图片路径
    public static final String FILE_QR_PATH = "/upload/qr";

    // 课程类目文件路径
    public static final String COURSE_CATEGORY_PATH = "/course/category";


    //图片的一级路径
    public static final String IMG_PREFIX = "/img";

    //视屏的一级路径
    public static final String AUDIO_PREFIX = "/audio";

    //课程的一级路径
    public static final String COURSE_PREFIX = "/course";

    /**
     * 图片的二级路径已枚举的形式存在
     */
    public enum SECOND_ENUM {

        // 课程目录及章节信息
        COURSE_INFO(100, "jxcxyrootFolder/courseInfo"),

        // 文章音频及倍速
        COURSE_AUDIO(101, "jxcxyrootFolder/courseAudio"),

        // 打卡语音
        COURSE_CARD(102, "jxcxyApprootFolder/cardRecord"),

        // 点评语音
        COURSE_COMMENT(103, "wkxcxrootFolder/reviewAudio"),

        // 临时文件【可以随时删除】
        TEMP(104, "temp"),

        // 打卡海报
        POSTER(105, "jxcxyrootFolder/poster"),

        CONTENT_RELEASE(106, "jxcxyrootFolder/contentRelease"),

        //直播类目图片
        LIVE_CATEGORY(107, "jxcxyApprootFolder/cardRecord"),

        // 头像
        HEAD_PORTRAIT(108, "yyxyAppMaterial/img/portrait/");

        /**
         * 文件编码
         */
        private Integer fileCode;

        /**
         * 文件路径
         */
        private String filePath;

        SECOND_ENUM(Integer fileCode, String filePath) {
            this.fileCode = fileCode;
            this.filePath = filePath;
        }

        /**
         * 根据枚举值获取枚举对象
         *
         * @param fileCode 文件Code
         */
        public static String getFilePath(Integer fileCode) {
            for (SECOND_ENUM secondEnum : SECOND_ENUM.values()) {
                if (fileCode.equals(secondEnum.getFileCode())) {
                    return secondEnum.getFilePath();
                }
            }
            return "";
        }

        /**
         * 生成枚举map
         *
         * @return
         */
        public static Map<Integer, Object> getEnumMap() {
            Map<Integer, Object> result = new HashMap<Integer, Object>();

            for (SECOND_ENUM second_enum : values()) {
                result.put(second_enum.getFileCode(), second_enum.getFilePath());
            }

            return result;
        }

        public Integer getFileCode() {
            return fileCode;
        }

        public void setFileCode(Integer fileCode) {
            this.fileCode = fileCode;
        }

        public String getFilePath() {
            return filePath;
        }

        public void setFilePath(String filePath) {
            this.filePath = filePath;
        }
    }


}
